package com.thinkgem.jeesite.modules.ship.web;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.QueryParam;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.modules.ship.entity.ShipSeaBookStat;
import com.thinkgem.jeesite.modules.ship.service.ShipSeaBookStatService;

/**
 * 出海预约信息Controller
 * 
 * @author lgx
 * @version 2016-04-17
 */
@Controller
@RequestMapping(value = "${adminPath}/ship/shipSeaBookStat")
public class ShipSeaBookStatController extends BaseController {

	@Autowired
	private ShipSeaBookStatService shipSeaBookStatService;

	// @RequiresPermissions("ship:shipSeaBookStat:view")
	@RequestMapping(value = { "shipSeaBookStatList", "" })
	public String list(ShipSeaBookStat shipSeaBookStat,
			HttpServletRequest request, HttpServletResponse response,
			Model model) {
		List<ShipSeaBookStat> shipSeaBookStatlist = shipSeaBookStatService
				.findAllList(shipSeaBookStat);
		model.addAttribute("shipSeaBookStatlist", shipSeaBookStatlist);
		return "modules/ship/shipSeaBookStatList";
	}

	@RequestMapping(value = { "queryShipSeaBookView" })
	public String queryShipSeaBookView(@RequestParam("year") int year,
			@RequestParam("month") int month,
			@RequestParam("weekDate") String weekDate,
			@RequestParam("dateTypeName") String dateTypeName) {
		List<ShipSeaBookStat> shipSeaBookStatlist = shipSeaBookStatService
				.findShipSeaBookView(year, month, weekDate, dateTypeName);
		
		for (int i = 0; i < shipSeaBookStatlist.size(); i++) {
              System.out.println("========"+shipSeaBookStatlist.get(i));
		}
		return "redirect:" + adminPath
				+ "/ship/shipSeaBook/shipSeaBookView?repage"+
				"&year="+year+
				"&month="+month+
				"&weekDate="+weekDate+
				"&dateTypeName="+dateTypeName;	
		}
	/**
	 * 将list泛型数据转成以分隔符分隔的字符串
	 * lists泛型数据
	 * separator分隔符  lg ,/.=-
	 * */
	public String listToString(List<String> lists, char separator) 
	{    
		StringBuilder sb = new StringBuilder();    
		for (int i = 0; i < lists.size(); i++) {        
				sb.append(lists.get(i)).append(separator);    
			}
		if(lists.size()>0){
			return sb.toString().substring(0,sb.toString().length()-1);
		}else{
			return "";
		}
		
	}
}